const CryptoJS = require('./crypto.js');
const aecConfig = {
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.Pkcs7
}
//加密方法
function TripleDES_EN(text) {
    // data = enc.Utf8.parse(data);
    // let tmpDES = TripleDES.encrypt(data, key, {
    //     iv: iv,
    //     mode: mode.CBC,
    //     padding: pad.Pkcs7
    // });
    // return tmpDES.toString()
    
    let key = CryptoJS.enc.Utf8.parse('code2023030108145310241024')
    let iv = CryptoJS.enc.Utf8.parse('10241024')
    const encrypted = CryptoJS.TripleDES.encrypt(text, key, { iv, ...aecConfig })
    return encrypted.toString()
}

//解密方法
function AES_DE(text) {
    let key = CryptoJS.enc.Utf8.parse('code2023030108145310241024')
    let iv = CryptoJS.enc.Utf8.parse('10241024')
    text = CryptoJS.enc.Hex.parse(text)
    const decrypt = CryptoJS.AES.decrypt({ ciphertext: text }, key, { iv, ...aecConfig })
    const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8)
    return decryptedStr.toString()
}
export {
    TripleDES_EN, AES_DE
}